.class public Lcom/nemustech/regina/widgets/clock/WeatherDBManager;
.super Ljava/lang/Object;
.source "WeatherDBManager.java"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 8
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getWeatherData(Landroid/content/Context;Ljava/lang/String;)Lcom/nemustech/regina/widgets/clock/WeatherData;
    .locals 12
    .parameter "con"
    .parameter "cityCode"

    .prologue
    const/4 v2, 0x0

    .line 29
    const/4 v10, 0x0

    .line 30
    .local v10, weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    new-instance v1, Ljava/lang/StringBuilder;

    invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "city_code=\'"

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    const-string v4, "\'"

    invoke-virtual {v1, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    .line 31
    .local v3, selQuery:Ljava/lang/String;
    invoke-virtual {p0}, Landroid/content/Context;->getContentResolver()Landroid/content/ContentResolver;

    move-result-object v0

    .line 32
    .local v0, cr:Landroid/content/ContentResolver;
    sget-object v1, Lcom/nemustech/regina/widgets/clock/WeatherData;->CONTENT_URI:Landroid/net/Uri;

    move-object v4, v2

    move-object v5, v2

    invoke-virtual/range {v0 .. v5}, Landroid/content/ContentResolver;->query(Landroid/net/Uri;[Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v8

    .line 33
    .local v8, cursor:Landroid/database/Cursor;
    if-eqz v8, :cond_2

    invoke-interface {v8}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v1

    if-eqz v1, :cond_2

    invoke-interface {v8}, Landroid/database/Cursor;->getCount()I

    move-result v1

    if-lez v1, :cond_2

    .line 35
    :try_start_0
    const-string v1, "city_code"

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v6

    .line 36
    .local v6, cityCodeIndex:I
    invoke-interface {v8, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v7

    .line 37
    .local v7, code:Ljava/lang/String;
    invoke-virtual {p1, v7}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 39
    new-instance v11, Lcom/nemustech/regina/widgets/clock/WeatherData;

    invoke-direct {v11}, Lcom/nemustech/regina/widgets/clock/WeatherData;-><init>()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 41
    .end local v10           #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    .local v11, weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    :try_start_1
    invoke-virtual {v11, v7}, Lcom/nemustech/regina/widgets/clock/WeatherData;->setCode(Ljava/lang/String;)V

    .line 42
    const-string v1, "location"

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v1

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v1

    invoke-virtual {v11, v1}, Lcom/nemustech/regina/widgets/clock/WeatherData;->setLocation(Ljava/lang/String;)V

    .line 43
    const-string v1, "last_update"

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v1

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v1

    invoke-static {v1, v2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    invoke-virtual {v11, v1}, Lcom/nemustech/regina/widgets/clock/WeatherData;->setLastUpdateTime(Ljava/lang/Long;)Ljava/lang/Long;

    .line 44
    const-string v1, "temp_units"

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v1

    invoke-interface {v8, v1}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-virtual {v11, v1}, Lcom/nemustech/regina/widgets/clock/WeatherData;->setUnits(I)V

    .line 46
    invoke-virtual {v11}, Lcom/nemustech/regina/widgets/clock/WeatherData;->getCurrentCondition()Lcom/nemustech/regina/widgets/clock/WeatherData$CurrentCondition;

    move-result-object v1

    const-string v2, "cur_temp"

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v1, v2}, Lcom/nemustech/regina/widgets/clock/WeatherData$CurrentCondition;->setTemp(I)V

    .line 47
    invoke-virtual {v11}, Lcom/nemustech/regina/widgets/clock/WeatherData;->getCurrentCondition()Lcom/nemustech/regina/widgets/clock/WeatherData$CurrentCondition;

    move-result-object v1

    const-string v2, "cur_weather"

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v1, v2}, Lcom/nemustech/regina/widgets/clock/WeatherData$CurrentCondition;->setWeather(I)V

    .line 49
    const/4 v9, 0x0

    .local v9, index:I
    :goto_0
    const/4 v1, 0x5

    if-ge v9, v1, :cond_0

    .line 50
    invoke-virtual {v11, v9}, Lcom/nemustech/regina/widgets/clock/WeatherData;->getForeCast(I)Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "for"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v4, "_date"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getLong(I)J

    move-result-wide v4

    invoke-static {v4, v5}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v2

    invoke-virtual {v1, v2}, Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;->setDate(Ljava/lang/Long;)V

    .line 52
    invoke-virtual {v11, v9}, Lcom/nemustech/regina/widgets/clock/WeatherData;->getForeCast(I)Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "for"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v4, "_temp_high"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v1, v2}, Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;->setTempHigh(I)V

    .line 54
    invoke-virtual {v11, v9}, Lcom/nemustech/regina/widgets/clock/WeatherData;->getForeCast(I)Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "for"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v4, "_temp_low"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v1, v2}, Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;->setTempLow(I)V

    .line 56
    invoke-virtual {v11, v9}, Lcom/nemustech/regina/widgets/clock/WeatherData;->getForeCast(I)Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;

    move-result-object v1

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    const-string v4, "for"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2, v9}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v4, "_weather"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getColumnIndexOrThrow(Ljava/lang/String;)I

    move-result v2

    invoke-interface {v8, v2}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-virtual {v1, v2}, Lcom/nemustech/regina/widgets/clock/WeatherData$ForeCast;->setWeather(I)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_1

    .line 49
    add-int/lit8 v9, v9, 0x1

    goto/16 :goto_0

    :cond_0
    move-object v10, v11

    .line 61
    .end local v9           #index:I
    .end local v11           #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    .restart local v10       #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    :cond_1
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    move-object v1, v10

    .line 64
    .end local v6           #cityCodeIndex:I
    .end local v7           #code:Ljava/lang/String;
    :goto_1
    return-object v1

    .line 61
    :catchall_0
    move-exception v1

    :goto_2
    invoke-interface {v8}, Landroid/database/Cursor;->close()V

    throw v1

    :cond_2
    move-object v1, v2

    .line 64
    goto :goto_1

    .line 61
    .end local v10           #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    .restart local v6       #cityCodeIndex:I
    .restart local v7       #code:Ljava/lang/String;
    .restart local v11       #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    :catchall_1
    move-exception v1

    move-object v10, v11

    .end local v11           #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    .restart local v10       #weatherData:Lcom/nemustech/regina/widgets/clock/WeatherData;
    goto :goto_2
.end method

.method public static sendChangePeriod(Landroid/content/Context;J)V
    .locals 2
    .parameter "con"
    .parameter "period"

    .prologue
    .line 23
    new-instance v0, Landroid/content/Intent;

    const-string v1, "com.nemustech.regina.weatherserver.UPDATE_PERIOD"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 24
    .local v0, intent:Landroid/content/Intent;
    const-string v1, "period"

    invoke-virtual {v0, v1, p1, p2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;J)Landroid/content/Intent;

    .line 25
    invoke-virtual {p0, v0}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V

    .line 26
    return-void
.end method

.method public static sendRequest(Landroid/content/Context;Ljava/lang/String;)V
    .locals 2
    .parameter "con"
    .parameter "cityCode"

    .prologue
    .line 11
    new-instance v0, Landroid/content/Intent;

    const-string v1, "com.nemustech.regina.weatherserver.REQUEST_WEATHER"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 12
    .local v0, intent:Landroid/content/Intent;
    const-string v1, "cityCode"

    invoke-virtual {v0, v1, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 13
    invoke-virtual {p0, v0}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V

    .line 14
    return-void
.end method

.method public static sendRequestRemove(Landroid/content/Context;Ljava/lang/String;)V
    .locals 2
    .parameter "con"
    .parameter "cityCode"

    .prologue
    .line 17
    new-instance v0, Landroid/content/Intent;

    const-string v1, "com.nemustech.regina.weatherserver.REMOVE_WEATHER"

    invoke-direct {v0, v1}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 18
    .local v0, intent:Landroid/content/Intent;
    const-string v1, "cityCode"

    invoke-virtual {v0, v1, p1}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 19
    invoke-virtual {p0, v0}, Landroid/content/Context;->sendBroadcast(Landroid/content/Intent;)V

    .line 20
    return-void
.end method
